home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.0
/
Video Toaster v4.0.iso
/
arexx
/
modeler
/
shell.lwm
< prev
next >
Wrap
Text File
|
1993-12-13
|
2KB
|
103 lines
/* CMD: Seashell
*
* Make a seashell from an outline shape.
*/
call addlib "rexxsupport.library", 0, -30, 0
signal on error
signal on syntax
call addlib "rexxmathlib.library", 0, -30, 0
call addlib "LWModelerARexx.port", 0
sysnam = 'Spin Seashell'
filnam = 'T:shell.state'
version = 'Seashell v1.0'
/* Setup state. Read stored one, if any.
*/
axis = 2
nrep = 4
nsid = 20
off = 1
scl = 0.6
if (exists(filnam)) then do
if (~open(state, filnam, 'R')) then break
if (readln(state) ~= version) then break
parse value readln(state) with axis nrep nsid off scl .
call close state
end
/* Post values for inspection and update.
*/
call req_begin sysnam
id_mes = req_addcontrol("Make a seashell",'T',"from an outline shape.")
id_axis = req_addcontrol("Axis", 'c', 'X Y Z')
id_nrep = req_addcontrol("# of Loops", 'n')
id_nsid = req_addcontrol("Sides per Loop", 'n')
id_off = req_addcontrol("Shift per Loop", 'n', 1)
id_scl = req_addcontrol("Scale per Loop", 'n')
call req_setval id_axis, axis
call req_setval id_nrep, nrep
call req_setval id_nsid, nsid
call req_setval id_off, off
call req_setval id_scl, scl
if (~req_post()) then do
call req_end
exit
end
axis = req_getval(id_axis)
nrep = req_getval(id_nrep)
nsid = req_getval(id_nsid) % 1
off = req_getval(id_off)
scl = req_getval(id_scl)
call req_end
/* Save state now, in case something fails.
*/
if (open(state, filnam, 'W')) then do
call writeln state, version
call writeln state, axis nrep nsid off scl
call close state
end
/* Perform shell sweep.
*/
n = (nsid * nrep) % 1 /* number of segments in shell */
v0 = subword('0 0', 1, axis - 1)
v1 = subword('0 0', 1, 3 - axis)
rot = 360.0 / nsid
cen = v0 (off * 1.0 / scl) v1
scl = pow(scl, 1.0 / nsid)
sc = 1.0
rt = 0.0
call repl_begin 'sweep'
call meter_begin n + 1, sysnam
do i = 0 to n
call repl_step 0, sc, v0 rt v1, cen
sc = sc * scl
rt = rt + rot
call meter_step
end i
call meter_end
call repl_end
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit